<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>年月日</title>
  <script type="text/javascript">
	function date1(){
		var myDate = new Date();
		var year = document.getElementById("year").value;
		var month = document.getElementById("month").value;
		var day = document.getElementById("day").value;
		myDate.setFullYear(year,month-1,day);
		var count;
		var i = 1;
		count = 0;
		while(i<=month){
			if(i==month){
				count=count+ Number(day);
			}else if (i==2){
				if (((year%4==0)&&(year%100!=0))||(year%400==0)){
					count = count +29;
				}else {
					count = count + 28;
				}
			}else if (i==4,6,9,11)
			{
				count = count + 30;
			}else {
				count = count +31;
			}
			i++;
		}
		document.getElementById("cha1").innerHTML= ("这是"+ year + "年的第"+ count +"天");
	}

	function week(){
		var myDate = new Date();
		var year = document.getElementById("year1").value;
		var month = document.getElementById("month1").value;
		var day = document.getElementById("day1").value;
		myDate.setFullYear(year,month-1,day);
		switch (myDate.getDay())
		{
			case 0: document.getElementById("cha2").innerHTML= "周日"; break;
			case 1: document.getElementById("cha2").innerHTML= "周一"; break;
			case 2: document.getElementById("cha2").innerHTML= "周二"; break;
			case 3: document.getElementById("cha2").innerHTML= "周三"; break;
			case 4: document.getElementById("cha2").innerHTML= "周四"; break;
			case 5: document.getElementById("cha2").innerHTML= "周五"; break;
			default: document.getElementById("cha2").innerHTML= "周六"; break;
		}
	}
  </script>
 </head>
 <body>


  <h4>输入一个年月日，判断该天是该年的第几天。</h4>
  <p id="cha1"></p>
  年：
  <input name="year" type="number" style="width:50px;" maxlength="4" id="year"/>&nbsp&nbsp
  月：
  <input name="month" type="number" style="width:40px;" maxlength="2" id="month"/>&nbsp&nbsp
  日：
  <input name="day" type="number" style="width:40px;" maxlength="2" id="day"/>&nbsp&nbsp
  <br/>
  <br/>
  <button onclick="date1()">submit</button><br/>
  <br/>



  <h4>输入一个年月日，判断该天使该年的第几周。</h4>
  <p id="cha2"></p>
  年：
  <input name="year1" type="number" style="width:50px;" maxlength="4" id="year1"/>&nbsp&nbsp
  月：
  <input name="month1" type="number" style="width:40px;" maxlength="2" id="month1"/>&nbsp&nbsp
  日：
  <input name="day1" type="number" style="width:40px;" maxlength="2" id="day1"/>&nbsp&nbsp
  <br/>
  <br/>
  <button onclick="week()">submit</button><br/>


 </body>
</html>
